#ifndef WEATHERNETWORK_H
#define WEATHERNETWORK_H

#include <QObject>
#include <QNetworkAccessManager>
#include <QNetworkReply>
#include <QNetworkRequest>
#include <QJsonDocument>
#include <QJsonObject>
#include <QJsonArray>
#include <QWidget>
#include <QMap>

#define URL "http://gfeljm.tianqiapi.com/api?unescape=1&version=v9&appid=77624539&appsecret=XFs2Dmgs"

class Widget;
class WeatherNetWork : public QObject
{
    Q_OBJECT
public:
    explicit WeatherNetWork(Widget *parent = nullptr);
    void getWeatherData(const QString& city = "");

private:
    QNetworkAccessManager* _manager;
    Widget* _parent;
    QMap<QString, QString> _qualityMap;
    QMap<QString, QString> _weatherMap;
    QMap<QString, QString> _cityCodeMap;
    void initMap();
    QString getCityCode(const QString& city);

private slots:
    void onNetworkReply(QNetworkReply* reply);

signals:

};

#endif // WEATHERNETWORK_H
